package com.vmj.classfile.entity.attribute;

import com.vmj.classfile.ClassReader;
import com.vmj.classfile.entity.ConstantPool;

/**
 * Created by yangshoujun on 2017/8/6 下午3:35.
 */
public class SourceFileAttribute extends AbstractAttribute {

    private ConstantPool constantPool;
    int sourceFileIndex;

    public SourceFileAttribute(ClassReader classReader) {
        super(classReader);
    }

    public ConstantPool getConstantPool() {
        return constantPool;
    }

    public void setConstantPool(ConstantPool constantPool) {
        this.constantPool = constantPool;
    }

    public void parse() {
        sourceFileIndex = getClassReader().readTwoByte();
    }

    public String getSourceFileName() {
        return constantPool.getUtf8(sourceFileIndex);
    }
}
